package com.bzkj.web.controller.msfx;

import com.bzkj.common.annotation.LogD;
import com.bzkj.common.core.controller.BaseController;
import com.bzkj.common.core.domain.AjaxResult;
import com.bzkj.common.core.page.TableDataInfo;
import com.bzkj.common.enums.BusinessType;
import com.bzkj.msfx.domain.CustomerMap;
import com.bzkj.msfx.service.CustomerMapService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;

/**
 * @projectName: btyy
 * @package: com.ruoyi.web.controller.basicinfo
 * @className: CustomerMapController
 * @description: 往来单位管理控制层
 * @author: C1309
 * @createDate: 2024年03月22日
 * @version: v1.0
 */
@RestController
@RequestMapping("/btrh/customerMap")
public class CustomerMapController extends BaseController {
    @Resource
    private CustomerMapService customerMapService;

    /**
     * 查询往来单位列表
     *
     * @param customerMap 条件查询
     * @return 查询结果
     */
    @GetMapping("/list")
    @PreAuthorize("@ss.hasPermi('basic:customermap:list')")
    public TableDataInfo queryCustomerMapList(CustomerMap customerMap) {
        startPage();
        ArrayList<CustomerMap> customerMaps = customerMapService.queryErpCustomer(customerMap);
        return getDataTable(customerMaps);
    }

    /**
     * 更新往来单位映射
     *
     * @param customerMap 更新数据
     * @return 更新结果
     */
    @PutMapping
    @PreAuthorize("@ss.hasPermi('basic:customermap:edit')")
    @LogD(title = "往来单位映射", businessType = BusinessType.UPDATE,
            tableNames = "customer_map", pkFieldNames = "id", request_url = "/customerMap/list")
    public AjaxResult updateCustomerMap(@RequestBody CustomerMap customerMap) {
        return customerMapService.updateCustomerMap(customerMap);
    }

}
